
package com.craterhill.java.ems.dao;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.craterhill.java.ems.common.beans.Country;
import com.craterhill.java.ems.dao.impl.AbstractDao;
import com.craterhill.java.ems.dao.utils.EMSResultSetExtractor;

public interface CountryDao extends EMSDao<Country> {

	public final String FIELD_LIST = "obj.country_id, obj.country_code, obj.country_name" + AbstractDao.MONITER_FIELDS;

	public final String FIND_ALL_COUNTRY = "select " + FIELD_LIST + " from country obj";

	public final class CountryExtractor extends EMSResultSetExtractor<Country> {

		@Override
		protected Country extractResultSetData(ResultSet resultSet) throws SQLException {
			Country country = new Country();
			country.setCountryId(resultSet.getInt(1));
			country.setCountryCode(resultSet.getString(2));
			country.setCountryName(resultSet.getString(3));
			country.setStatus(resultSet.getBoolean(4));
			country.setCreatedBy(resultSet.getInt(5));
			country.setCreatedDate(resultSet.getDate(6));
			country.setModifiedDate(resultSet.getDate(7));
			return country;
		}
	}
}
